<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./site/admin/_pre.php, $Author:  $ */

define('FORCE_NO_GZIP', true);

App::membersOnly();

$oBanService = &App::getModuleService('Site', 'Ban');
/* @var $oBanService PhpFox_Mod_Site_ServiceBan */
$oBanService->checkIPBan();
$oReq = &App::getRequest();
$oUrl = &App::getUrl();

$oSecurity = App::getModuleService('Account', 'Security');
/* @var $oSecurity PhpFox_Mod_Account_ServiceSecurity */
$oCurrUser = &$oSecurity->getCurrentUser();

if ( !$oCurrUser || !$oSecurity->isStaff())
{
    App::gotoUrl('public.account');
}

if ( !$oSecurity->isStaffAllowed(App::getPage()) )
{
	App::gotoUrl('admin');
}

if (eregi('admin\.plugins', App::getPage()) && !$oSecurity->isStaffAllowed('admin.plugins'))
{
	App::gotoUrl('admin');
}

if ( App::getParam('adminHttp') )
{
 	if ( !isset($_SERVER['PHP_AUTH_USER']) AND !isset($_SERVER['PHP_AUTH_PW']) )
 	{
		App::forceLogin();
 	}
 	if ( md5($_SERVER['PHP_AUTH_USER']) != md5($oCurrUser->aData['user']) AND md5($_SERVER['PHP_AUTH_PW']) != md5($oCurrUser->aData['password']) )
 	{
 		App::forceLogin();
	}
}

$oSrvLog = App::getModuleService('Log', 'Log');
/* @var $oSrvLog PhpFox_Mod_Log_ServiceLog */
$oSrvLog->addSiteSession($oCurrUser);

$oTpl = &App::getTemplate();
$oTpl->assignSrc(array(
    'sSlogan'        => App::getSetting('site_name'),
	'oCurrUser'      => $oCurrUser,
	'aCurrUser'      => $oCurrUser->aData,
	'bUseTinyMCE' => ($oReq->get('wysiwyg') ? true : false),
	'sCurrentPage' => base64_encode(App::getPage()),
	'sPathTransJs'   => App::makeJSPathTranslatedValue()
));
?>